
import java.util.Scanner;

public class shopping1 {
    public static void main(String[] args) {
//        声明5个小数类型的变量来存储5件商品的价格
        Double tootbrshPrice =8.8;
        Double towelPrice =10.0;
        Double cupPrice =18.8;
        Double applePrice =12.5;
        Double bananaPrice =15.5;
        System.out.println("-------------购物商城---------------");
        System.out.println("牙刷的价格是"+tootbrshPrice+"元");
        System.out.println("毛巾的价格是"+towelPrice+"元");
        System.out.println("水杯的价格是"+cupPrice+"元");
        System.out.println("苹果的价格是"+applePrice+"元");
        System.out.println("香蕉的价格是"+bananaPrice+"元");
        String flag = "Y";
        Scanner scanner =new Scanner(System.in);
//        String提供方法有（equals（）方法，用于比较字符串本身
//        结果是一个boolean类型的值，如果相等则返回true,反之返回fause
        do{
            System.out.println("请输入您要购买的商品序列号：");
            int num = scanner.nextInt();
            System.out.println("请输入您要购买的商品数量：");
            int count = scanner.nextInt();
            switch(num){
                    case 1://牙刷
                    System.out.println("你购买的牙刷" + count +"支，总价是："+(tootbrshPrice*count));
                    System.out.println("继续购买输入Y，否则输入N");
                    flag = scanner.next();
                    break;
                    case 2://毛巾
                    System.out.println("你购买的毛巾" + count +"个，总价是："+(towelPrice*count));
                System.out.println("继续购买输入Y，否则输入N");
                flag = scanner.next();
                    break;
                    case 3://杯子
                    System.out.println("你购买的杯子" + count +"个，总价是："+(cupPrice*count));
                System.out.println("继续购买输入Y，否则输入N");
                flag = scanner.next();
                    case 4://苹果
                    System.out.println("你购买的苹果" + count +"个，总价是："+(applePrice*count));
                System.out.println("继续购买输入Y，否则输入N");
                flag = scanner.next();
                    break;
                    case 5://香蕉
                    System.out.println("你购买的香蕉" + count +"个，总价是："+(bananaPrice*count));
                System.out.println("继续购买输入Y，否则输入N");
                flag = scanner.next();
                    break;
                default:
                    System.out.println("您要购买的货物不存在");
                    break;
            }

        }while(flag.equals("Y")); //判断条件值是Y
        System.out.println("欢迎下次光临");
    }
}
